package com.cax.common.listener;

import com.cax.common.utils.spring.SpringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/**
 * 项目启动成功后的监听
 * 这里这打印一些信息
 */
@Slf4j
@Component
public class PrintBanner implements ApplicationListener<ApplicationReadyEvent> {
    @Value("${cax.name}")
    private String applicationName;

    @Override
    public void onApplicationEvent(ApplicationReadyEvent event) {
        log.info("配置文件："+ String.join(",", SpringUtils.getActiveProfiles()));
        log.info("端口："+SpringUtils.getRequiredProperty("server.port"));
        log.info("启动成功："+applicationName);
    }



}
